package com.heima.behavior.behaviorController;

import com.heima.behavior.service.ApArticleBehaviorService;
import com.heima.behavior.service.ApCollectionBehaviorService;
import com.heima.behavior.service.ApLikesBehaviorService;
import com.heima.behavior.service.ApReadBehaviorService;
import com.heima.behavior.service.ApUnlikeBehaviorService;
import com.heima.model.behavior.dtos.ArticleBehaviorDTO;
import com.heima.model.behavior.dtos.CollectionBehaviorDTO;
import com.heima.model.behavior.dtos.LikesBehaviorDTO;
import com.heima.model.behavior.dtos.ReadBehaviorDTO;
import com.heima.model.behavior.dtos.UnLikesBehaviorDTO;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.threadlocal.AppThreadLocalUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/")
public class UserBehaviorController {

    @Autowired
    ApLikesBehaviorService apLikesBehaviorService;

    @Autowired
    ApReadBehaviorService apReadBehaviorService;

    @Autowired
    ApUnlikeBehaviorService apUnlikeBehaviorService;

    @Autowired
    ApCollectionBehaviorService apCollectionBehaviorService;

    @Autowired
    ApArticleBehaviorService apArticleBehaviorService;
    /**
     * 赞/取消赞
     * @param dto
     * @return
     */
    @PostMapping("likes_behavior")
    public ResponseResult likeBehavior(@RequestBody LikesBehaviorDTO dto){
        System.out.println(dto);
        return apLikesBehaviorService.like(dto);
    }

    @PostMapping("read_behavior")
    public ResponseResult readbehavior(@RequestBody ReadBehaviorDTO dto){
        return apReadBehaviorService.readBehavior(dto);
    }


    @PostMapping("un_likes_behavior")
    public ResponseResult unLikesBehavior(@RequestBody UnLikesBehaviorDTO dto){
        System.out.println("爷不喜欢");
        return apUnlikeBehaviorService.unlikeBehavior(dto);
    }

    @PostMapping("collection_behavior")
    public ResponseResult collectionBehavior(@RequestBody CollectionBehaviorDTO dto){
        System.out.println("爷收藏"+dto);
        return apCollectionBehaviorService.collectBehavior(dto);
    }

    @PostMapping("article/load_article_behavior")
    public ResponseResult loadArticleBehavior(@RequestBody ArticleBehaviorDTO dto){
        System.out.println("爷回显"+dto);
        return apArticleBehaviorService.loadArticleBehavior(dto);
    }
}
